package com.example.module_service.vm

import com.example.lib_common.view.vm.BaseViewModel
import com.example.module_service.api.ServiceApiService
import com.example.module_service.entity.CarStopEntityItem
import com.example.module_service.model.ServiceRepository
import com.example.module_service.model.ServiceResultData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class CarStopViewModel @Inject constructor(private val apiService: ServiceApiService):
    BaseViewModel<ServiceRepository, ServiceResultData<List<CarStopEntityItem>>>(){

    fun getCarStop(){
        mViewModelScope.launch (mDispatcher){
            try{
                val result=apiService.getCarStop()
                val res=ServiceResultData(
                    code = result.code,
                    message = result.message,
                    data =result.data
                )
                mSuccessLiveData.postValue(res)
            }catch (e:Exception){
                mErrorLiveData.postValue("请求失败:${e.message}")
            }
        }
    }

}